package jude.java.money.migrate;

import java.io.IOException;

public class Migrate {
	
	private static final String BASE_PATH = "E:\\php\\Backups\\migrate\\";
	private static final String DATABASE_NAME_PREFIX = "migrate_";
	private static final String NEW_END_DATE = "2012-02-01";
	
	public static void main(String[] args) throws IOException {
//		ferragamomen2();
//		uggeoutlet2();
//		moncler2();
		toryburch();
//		test();
	}
	
	private static Zencart2Magento get(String name) throws IOException {
		Zencart2Magento m = new Zencart2Magento(name, DATABASE_NAME_PREFIX + name);
		m.setOutputPath("E:\\import\\");
		m.setProductImagePath(true, BASE_PATH + name + "\\", "E:\\import\\", 10);
		m.setAttributeSet("UES Default", false, null);
		m.setExtraAttributes("gender");
//		m.setLimit(0, 3);
		return m;
	}

	/** uggeoutlet.com */
	static void uggeoutlet2() throws IOException {
		Zencart2Magento m = get("ugg");
//		m.setProductCategories(false, "By Brand/UGG");
//		m.setProductAsNewDate("2010-11-01", "2012-06-29");
		m.setProductAsNewDate(true, NEW_END_DATE);
		String[] categories = new String[] {
				"Women's Shoes/Flats",
				"Women's Shoes/Flip Flops",
				"Women's Shoes/Sandals",	//Heel Sandals
				"Women's Shoes/Boots",
				"Men's Boots",
				"Boots for Kids/Infants' Boots",
				"Boots for Kids/Kids' Boots",
				"UGG Handbags",
		};

		String[][] categoryGroups = new String[][] {
				{"UGG Dakota Casuals boots"},
				
				{"UGG Fluff Flip Flop"},
				
				{"UGG Amelie Suede"},

				{"UGG Bailey Button Triplet",
				"UGG Knightsbridge boots",
				"UGG Fluff Flip Flop",
				"UGG Sundance boots",
				"UGG Nightfall boots",
				"UGG Sandra boots",
				"UGG Felicity boots",
				"UGG Adirondack boots",
				"UGG Liberty boots",
				"UGG Broome boots",
				"UGG Chrystie boots",
				"UGG Gissella boots",
				"UGG Seline boots",
				"UGG Elsey boots",
				"UGG Langley boots",
				"UGG Payton boots",
				"UGG Kensington boots",
				"UGG Classic Tall boots",
				"UGG Roseberry boots",
				"UGG Corinth boots",
				"UGG Ashur boots",
				"UGG Highkoo boots",
				"UGG Bailey Button boots",
				"UGG Classic Cardy boots",
				"UGG Stripe Cable Knit boots",
				"UGG Classic Short boots",
				"UGG Classic Mini boots",
				"UGG Classic Argyle Knit boots"},

				{"Men's Classic Mini boots",
				"Men's Classic Short boots"},

				{"Infant's Erin Baby boots"},

				{"Kid's UGG Classic Tall boots",
				"Kid's UGG Classic Short boots",
				"Kid's Bailey Button boots"},
				
				{"UGG Handbags"},
		};
		String[][] extras = new String[][] {
				{"By Categories/Shoes/Flats"},
				{"By Categories/Shoes/Slippers"},
				{"By Categories/Shoes/Sandals"},
				{"By Categories/Shoes/Boots"},
				{"By Categories/Shoes/Boots"},
				{"By Categories/Shoes/Boots"},
				{"By Categories/Shoes/Boots"},
				{"By Categories/Bags/Handbags"},
		};
		m.setHandlers(new FieldHandlers()
//				.add(Zencart2Magento.FIELD_SKU, FieldHandlers.idHandler("UGG", 1001 + start))
//				.add("gender", FieldHandlers.GENDER_HANDLER)
				.add(Zencart2Magento.FIELD_NAME, "ugg", "UGG")
				.add(Zencart2Magento.FIELD_DESCRIPTION, FieldHandlers.REMOVE_LINK_HANDLER)
				//图片字段第一次先不要使用, 可以检测重复使用的图片
				.add(Zencart2Magento.FIELD_IMAGE, FieldHandlers.renameImageHandler("/ugg/", false))
//				.add(Zencart2Magento.FIELD_URL_KEY, FieldHandlers.urlkeyHandler("ferragamo"))
				.add(Zencart2Magento.FIELD_CATEGORY, FieldHandlers.groupHandler(categories, categoryGroups, extras))//合并分类
				.add(Zencart2Magento.FIELD_ATTRIBUTE_ITEM_SKU, FieldHandlers.simplifyHandler(true, "\\s(US\\s?[\\d\\.]+)[\\-=\\s]", 
						"^(US[\\d\\.]+)[\\-=\\s]", "^Baby (\\w+)="))
				.add(Zencart2Magento.FIELD_ATTRIBUTE_SKU, FieldHandlers.multiHandler(FieldHandlers.ATTRIBUTE_SKU_HANDLER))
				.add(Zencart2Magento.FIELD_NAME, FieldHandlers.multiHandler(FieldHandlers.trimHandler(" outlet", "on sale", "for cheap", "cheap"), FieldHandlers.CAPITALIZE_HANDLER))
				);
		m.setTablePrefix("zen_", "ues_");
		m.setManufacturer("UGG");
		m.setCategoryPrefix("UGG/");
		m.setFilterCategoryNames(true, false, null);
//		m.setExtraAttributes("");
//		m.setCategoryPrefix("Shoes/UGG/");
		m.migrate();
	}
	
	/** ferragamomen.com */
	static void ferragamomen2() throws IOException {
		Zencart2Magento m = get("ferragamo");
//		m.setProductCategories(false, "By Brand/Ferragamo");
//		m.setProductAsNewDate("2011-09-01", "2012-02-29");
		m.setProductAsNewDate(true, NEW_END_DATE);
		String[] categories = new String[] {
			"Ferragamo Shoes/Men's Shoes",
			"Ferragamo Shoes/Flat Shoes",
			"Ferragamo Shoes/High Heel Shoes",
			"Ferragamo Shoes/Heel Sandals",
			"Ferragamo Bags/Handbags",
			"Ferragamo Bags/Men's Bags",
			"Ferragamo Bags/Wallets",
			"Ferragamo Belts",
			"More Ferragamo/Sunglasses",
			"More Ferragamo/Perfume",
		};
		String[][] categoryGroups = new String[][] {
				{"Ferragamo Flat Men", "Ferragamo Men Shoes"},
				{"Ferragamo Flat Women", "Ferragamo Varina Flats"},
				{"Ferragamo High Heel Shoes"},
				{"Ferragamo Heel Sandals"},
				{"Ferragamo Handbags"},
				{"Ferragamo Leather Bags"},
				{"Ferragamo Mens Wallets"},
				{"Ferragamo Belts"},
				{"Ferragamo Sunglasses"},
				{"Ferragamo Perfume", "Ferragamo perfume"},
		};
		String[][] extras = new String[][] {
				{"By Categories/Shoes/Flats"},
				{"By Categories/Shoes/Flats"},
				{"By Categories/Shoes/High Heels"},
				{"By Categories/Shoes/Sandals"},
				{"By Categories/Bags/Handbags"},
				{"By Categories/Bags/Handbags"},
				{"By Categories/Bags/Wallets"},
				{"By Categories/Accessories/Belts"},
				{"By Categories/Accessories/Sunglasses"},
				{"By Categories/More/Perfume"},
		};
		m.setHandlers(new FieldHandlers()
				.add(Zencart2Magento.FIELD_SKU, FieldHandlers.idHandler("FRGM", 1001 + m.getFirst()))
//				.add("gender", FieldHandlers.GENDER_HANDLER)
				.add(Zencart2Magento.FIELD_DESCRIPTION, FieldHandlers.REMOVE_LINK_HANDLER)
				//图片字段第一次先不要使用, 可以检测重复使用的图片
				.add(Zencart2Magento.FIELD_IMAGE, FieldHandlers.renameImageHandler("/ferragamo/", true))
//				.add(Zencart2Magento.FIELD_URL_KEY, FieldHandlers.urlkeyHandler("ferragamo"))
				.add(Zencart2Magento.FIELD_CATEGORY, FieldHandlers.groupHandler(categories, categoryGroups, extras))//合并分类
				.add(Zencart2Magento.FIELD_ATTRIBUTE_ITEM_SKU, FieldHandlers.simplifyHandler(true, "/(US\\s?[\\d\\.]+)/", 
						"^(US[\\d\\.]+)\\-", "= (\\d+\\s?cm)"))
				.add(Zencart2Magento.FIELD_ATTRIBUTE_SKU, FieldHandlers.multiHandler(FieldHandlers.trimHandler("ferragamo"), FieldHandlers.ATTRIBUTE_SKU_HANDLER))
				.add(Zencart2Magento.FIELD_NAME, FieldHandlers.multiHandler(FieldHandlers.trimHandler("outlet", "on sale", "for cheap", "cheap"), FieldHandlers.CAPITALIZE_HANDLER))
				);
		m.setTablePrefix("", "ues_");
		m.setManufacturer("Ferragamo");
		m.setCategoryPrefix("Ferragamo/");
		m.migrate();
	}
	
	/** moncler.tk */

	static void moncler2() throws IOException {
		Zencart2Magento m = get("moncler");
//		m.setProductCategories(false, "By Brand/Moncler");
		m.setProductAsNewDate(true, NEW_END_DATE);
		
		String[] categories = new String[] {
			"Down Jackets/Women's Jackets",
			"Down Jackets/Men's Jackets",
			"Down Jackets/Kids' Jackets",
			"Moncler Vest/Women's Vests",
			"Moncler Vest/Men's Vests",
			"More Moncler/Men's Sweaters",
			"More Moncler/Cap & Scarf",
			"More Moncler/Bags",
			"More Moncler/Moncler Shoes",
		};
		String[][] categoryGroups = new String[][] {
				{"Women Moncler"},
				{"Men Moncler"},
				{"Kids Moncler"},
				{"Women Moncler Vest"},
				{"Men Moncler Vest"},
				{"Men Moncler Sweaters"},
				{"Accessories Moncler"},
				{"Bags Moncler"},
				{"Men Moncler Shoes"},
		};
		String[][] extras = new String[][] {
				{"By Categories/Clothing/Jackets"},
				{"By Categories/Clothing/Jackets"},
				{"By Categories/Clothing/Jackets"},
				{"By Categories/Clothing/Vests"},
				{"By Categories/Clothing/Vests"},
				{"By Categories/Clothing/Sweaters"},
				{"By Categories/Accessories/Hats & Scarfs"},
				{"By Categories/Bags/Handbags"},
				{"By Categories/Shoes/Casual Shoes"},
		};
		m.setHandlers(new FieldHandlers()
//				.add(Zencart2Magento.FIELD_SKU, FieldHandlers.idHandler("Moncler", 1001 + start))
//				.add("gender", FieldHandlers.GENDER_HANDLER)
				.add(Zencart2Magento.FIELD_NAME, "moncler", "Moncler")
//				.add(Zencart2Magento.FIELD_ATTRIBUTE_SKU, FieldHandlers.ATTRIBUTE_SKU_HANDLER)
				.add(Zencart2Magento.FIELD_DESCRIPTION, FieldHandlers.REMOVE_LINK_HANDLER)
				//图片字段第一次先不要使用, 可以检测重复使用的图片
				.add(Zencart2Magento.FIELD_IMAGE, FieldHandlers.renameImageHandler("/moncler/", false))
//				.add(Zencart2Magento.FIELD_IMAGE, "ugg\\-outlet", "ugg")
//				.add(Zencart2Magento.FIELD_URL_KEY, FieldHandlers.urlkeyHandler("ferragamo"))
				.add(Zencart2Magento.FIELD_CATEGORY, FieldHandlers.groupHandler(categories, categoryGroups, extras))//合并分类
				.add(Zencart2Magento.FIELD_ATTRIBUTE_ITEM_SKU, FieldHandlers.simplifyHandler(true, "^(\\d / [SMLX]+)\\s", "^([SMLX]{1,4})=", "=(US\\d+)="))
				.add(Zencart2Magento.FIELD_ATTRIBUTE_SKU, FieldHandlers.multiHandler(FieldHandlers.ATTRIBUTE_SKU_HANDLER))
				.add(Zencart2Magento.FIELD_NAME, FieldHandlers.multiHandler(FieldHandlers.trimHandler("outlet", "on sale", "for cheap", "cheap"), FieldHandlers.CAPITALIZE_HANDLER))
				);
		m.setTablePrefix("", "ues_");
		m.setManufacturer("Moncler");
		m.setCategoryPrefix("Moncler/");
		m.setFilterCategoryNames(true, false, null);
//		m.setCategoryPrefix("Shoes/UGG/");
		m.migrate();
	}

	static void toryburch() throws IOException {
		Zencart2Magento m = get("toryburch");
//		m.setProductCategories(false, "By Brand/Moncler");
		m.setProductAsNewDate(true, "2012-04-01");
		
		String[] categories = new String[] {
				"Boots",
				"Flats",
				"Flip Flops",
				"High Heels",
				"Low Heels",
				"Flats",
				"High Heels",
		};
		String[][] categoryGroups = new String[][] {
				{"Tory Burch Boots"},
				{"Tory Burch Flats"},
				{"Tory Burch Flip Flops"},
				{"Tory Burch High Heels"},
				{"Tory Burch Low Heels"},
				{"Tory Burch Shoes"},
				{"Tory Burch Wedges"},
		};
		String[][] extras = new String[][] {
				{"By Categories/Shoes/Boots"},
				{"By Categories/Shoes/Flats"},
				{"By Categories/Shoes/Slippers"},
				{"By Categories/Shoes/High Heels"},
				{"By Categories/Shoes/Low Heels"},
				{"By Categories/Shoes/Flats"},
				{"By Categories/Shoes/High Heels"},
		};
		m.setHandlers(new FieldHandlers()
//				.add(Zencart2Magento.FIELD_SKU, FieldHandlers.idHandler("Moncler", 1001 + start))
//				.add("gender", FieldHandlers.GENDER_HANDLER)
//				.add(Zencart2Magento.FIELD_NAME, "moncler", "Moncler")
//				.add(Zencart2Magento.FIELD_ATTRIBUTE_SKU, FieldHandlers.ATTRIBUTE_SKU_HANDLER)
				.add(Zencart2Magento.FIELD_DESCRIPTION, FieldHandlers.REMOVE_LINK_HANDLER)
				//图片字段第一次先不要使用, 可以检测重复使用的图片
				.add(Zencart2Magento.FIELD_IMAGE, FieldHandlers.renameImageHandler("/toryburch/", false))
//				.add(Zencart2Magento.FIELD_IMAGE, "ugg\\-outlet", "ugg")
//				.add(Zencart2Magento.FIELD_URL_KEY, FieldHandlers.urlkeyHandler("ferragamo"))
				.add(Zencart2Magento.FIELD_CATEGORY, FieldHandlers.groupHandler(categories, categoryGroups, extras))//合并分类
				.add(Zencart2Magento.FIELD_ATTRIBUTE_ITEM_SKU, FieldHandlers.simplifyHandler(true, "(US\\d+)"))
				.add(Zencart2Magento.FIELD_ATTRIBUTE_SKU, FieldHandlers.multiHandler(FieldHandlers.ATTRIBUTE_SKU_HANDLER))
				.add(Zencart2Magento.FIELD_NAME, FieldHandlers.multiHandler(FieldHandlers.trimHandler("Cheap", "On Sale", "online", "Sale", "Sales"), FieldHandlers.CAPITALIZE_HANDLER))
				);
		m.setTablePrefix("", "ues_");
		m.setManufacturer("Tory Burch");
		m.setCategoryPrefix("Tory Burch/Shoes/");
		m.setFixedMultiImages(true);
//		m.setFilterCategoryNames(true, false, null);
//		m.setCategoryPrefix("Shoes/UGG/");
		m.migrate();
	}
	
	static void test() throws IOException {
		Zencart2Magento m = get("test");
//		m.setProductCategories(false, "By Brand/Moncler");
//		m.setProductAsNewDate("2011-08-01", "2012-02-27");
		
		m.setHandlers(new FieldHandlers()
//				.add(Zencart2Magento.FIELD_SKU, FieldHandlers.idHandler("UGG", 1001 + start))
//				.add("gender", FieldHandlers.GENDER_HANDLER)
//				.add(Zencart2Magento.FIELD_NAME, "moncler", "Moncler")
//				.add(Zencart2Magento.FIELD_ATTRIBUTE_SKU, FieldHandlers.ATTRIBUTE_SKU_HANDLER)
//				.add(Zencart2Magento.FIELD_DESCRIPTION, FieldHandlers.REMOVE_LINK_HANDLER)
				//图片字段第一次先不要使用, 可以检测重复使用的图片
//				.add(Zencart2Magento.FIELD_IMAGE, FieldHandlers.renameImageHandler("/moncler/", false))
//				.add(Zencart2Magento.FIELD_IMAGE, "ugg\\-outlet", "ugg")
//				.add(Zencart2Magento.FIELD_URL_KEY, FieldHandlers.urlkeyHandler("ferragamo"))
//				.add(Zencart2Magento.FIELD_CATEGORY, FieldHandlers.groupHandler(categories, categoryGroups))//合并分类
				);
		m.setTablePrefix("", "ues_");
//		m.setManufacturer("Moncler");
		m.setFilterCategoryNames(true, false, null);
//		m.setCategoryPrefix("Shoes/UGG/");
		m.migrate();
	}
}
